<div class="tabbable tabs-left">
    <ul class="nav nav-tabs">
        <li><h5><?php echo $this->translate('商品索引'); ?></h5></li>
        <li class="active"><a data-toggle="tab" href="#goods_index_a"><?php echo $this->translate('基本信息'); ?></a></li>
    </ul>
    <form class="form-horizontal" method="post" name="goods_index_form" id="goods_index_form" action="">
        <div class="tab-content">
            <div id="sticky_navigation" style="height:30px;border-bottom:4px solid #DFDFDF;">
                <div class="pull-left" style="font-size:16px;line-height:30px;"><strong><?php echo $this->translate('商品索引'); ?></strong></div>
                <div id="sticky_navigation_right" class="pull-right">
                    <button type="submit" class="btn btn-small btn-primary"><i class="icon-ok icon-white"></i> <?php echo $this->translate('保存索引设置'); ?></button>&nbsp;
                    <a href="<?php echo $this->myviewalias()->dbshopHelpUrl('goods_index_set'); ?>" target="_blank" class="btn btn-small btn-info"><i class="icon-info-sign icon-white"></i> <?php echo $this->translate('查看帮助说明'); ?></a>
                </div>
            </div>
            <div id="goods_index_a" class="tab-pane active">
                <div class="well admin_add_header_well"><?php echo $this->translate('基本信息'); ?></div>
                <div class="well admin_add_well">
                    <div class="message_one">
                    </div>
                    <div class="alert alert-success" id="start_update_goodsindex" style="display:none; background-color:#FFF;"> <img src="<?php echo $this->basePath('public/admin/img/update_loading.gif'); ?>" border="0" /><strong><?php echo $this->translate('正在更新索引……，请您耐心等待，更新过程中请不要关闭此页面！'); ?></strong> </div>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('索引说明'); ?>：</label>
                        <div class="controls">
                            <label style="line-height: 30px;"><?php echo $this->translate('首次开启，如果系统内已经有商品，请点击下面的 <b>更新按钮</b> 进行更新。想了解 <b>商品索引</b> 请点击右上角 <b>查看帮助说明</b>。'); ?></label>
                        </div>
                    </div>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('商品索引'); ?>：</label>
                        <div class="controls">
                            <label class="checkbox"><input type="checkbox" value="true" name="goods_index" <?php if($this->goods_index == 'true') echo 'checked'; ?>><?php echo $this->translate('启用'); ?></label>
                        </div>
                    </div>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('商品总数'); ?>：</label>
                        <div class="controls">
                            <label style="line-height: 30px;"><?php echo $this->goods_count; ?><?php echo $this->translate('个'); ?></label>
                        </div>
                    </div>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('未索引商品数'); ?>：</label>
                        <div class="controls">
                            <label style="line-height: 30px;">
                                <?php echo $this->goods_count-$this->goods_index_count; ?><?php echo $this->translate('个'); ?>
                                &nbsp;&nbsp;[<b><?php echo $this->translate('未索引商品包括没有设置商品分类或者商品分类被禁用的商品'); ?></b>]
                            </label>
                        </div>
                    </div>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('已索引商品数'); ?>：</label>
                        <div class="controls">
                            <label style="line-height: 30px;"><?php echo $this->goods_index_count; ?><?php echo $this->translate('个'); ?></label>
                        </div>
                    </div>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('操作'); ?>：</label>
                        <div class="controls">
                            <button type="button" class="btn btn-primary" onclick="dbshop_start_goodsindex_update();"><?php echo $this->translate('点击更新商品索引'); ?></button>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </form>
</div>
<script>
    <?php if ($this->success_msg != '') { ?>
    show_message('.message_one','<?php echo date("Y-m-d H:i:s"); ?>','<?php echo $this->success_msg; ?>','alert-success');
    <?php } ?>

    function dbshop_start_goodsindex_update() {
        $('#start_update_goodsindex').css('display', '');
        $.post("<?php echo $this->url('goods/default', array('action'=>'updateGoodsIndex')); ?>",$('#goods_index_form').formSerialize(),
            function(data){
                if(data == 'true') {
                    alert('<?php echo $this->translate('索引更新成功！'); ?>');
                    window.location.href="<?php echo $this->url('goods/default', array('action'=>'goodsIndex')); ?>";
                } else {
                    alert(data);
                    window.location.href="<?php echo $this->url('goods/default', array('action'=>'goodsIndex')); ?>";
                }
            });
    }
</script>
